package com.b2b2c.until;

import java.util.List;

/**
 * 联合实体类
 * 
 * @author Administrator
 *
 */
public class UniteEntity<M, A> {

	private List<M> entityMaster;

	private List<A> entityAccess;

	public UniteEntity(List<M> entityMaster, List<A> entityAccess) {
		this.entityAccess = entityAccess;

		this.entityMaster = entityMaster;
	}

	/**
	 * 获取主键编号字符串
	 */
	public String getIdString(String method) {
		if (this.entityMaster == null || this.entityMaster.isEmpty()) {
			return "";
		}

		int i = this.entityMaster.size();

		int j;

		M obj;

		StringBuilder str = new StringBuilder("");

		String key;

		try {
			for (j = 0; j < i; j++) {

				obj = this.entityMaster.get(j);

				key = obj.getClass().getMethod(method).invoke(obj).toString();

				str.append(",").append(key);
			}
		} catch (Exception e) {
			// TODO: handle exception
			// e.printStackTrace();
			return "";
		}
		return str.substring(1);
	}

}
